const log = require('./utiles/log');
const loger = log('LifeCyclePlugin');

function logTypes(args) {
  console.log(...args.map((arg) => Object.prototype.toString.call(arg, arg)));
}

class LifeCyclePlugin {
  apply(compiler) {
    compiler.hooks.entryOption.tap('LifeCyclePlugin', (...args) => {
      loger('entryOption', args.length);
      logTypes(args);
    });
    compiler.hooks.afterPlugins.tap('LifeCyclePlugin', (...args) => {
      loger('afterPlugins', args.length);
      logTypes(args);
    });
    compiler.hooks.compilation.tap('LifeCyclePlugin', (...args) => {
      loger('compilation', args.length);
      logTypes(args);
    });
    compiler.hooks.emit.tap('LifeCyclePlugin', (...args) => {
      loger('emit', args.length);
      logTypes(args);
    });
    compiler.hooks.done.tap('LifeCyclePlugin', (...args) => {
      loger('done', args.length);
      logTypes(args);
    });
  }
}

module.exports = LifeCyclePlugin;
